package org.example.proxy;

/**
 * @version: 1
 * @description: java
 * @author: java
 * @create: 2020-06-04 20:45
 * 静态代理：特点
 *  代理类和被代理类在编译期间就被确定下来了
 **/
public interface PhoneFactory {
    void producePhone();
}

class ProxyFactory implements PhoneFactory {

    private PhoneFactory phoneFactory;

    public ProxyFactory(PhoneFactory phoneFactory) {
        this.phoneFactory = phoneFactory;
    }

    @Override
    public void producePhone() {
        System.out.println("方法增强开始");
        phoneFactory.producePhone();
        System.out.println("方法增强结束");
    }
}

class FactoryImpl implements PhoneFactory {

    @Override
    public void producePhone() {
        System.out.println("生产了一部手机");
    }
}

class test {
    public static void main(String[] args) {
        FactoryImpl factoryImpl = new FactoryImpl();
        PhoneFactory proxyFactory = new ProxyFactory(factoryImpl);
        proxyFactory.producePhone();
    }
}